package com.zhangfei.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Component
@Slf4j
public class ThreadPoolManager {


    /**
     * 默认队列大小 1000
     */
    private static final Integer DEFAULT_QUEUE_SIZE = Integer.MAX_VALUE;

    /**
     * 默认队列大小 1000
     */
    private static final Integer QUEUE_SIZE = 10240;
    private static final Integer CORE_POOL_SIZE = 16;
    private static final Integer MAX_POOL_SIZE = 32;
    private static final Integer KEEP_ALIVE_TIME = 30;

    /**
     * 导入导出
     */
    public static ThreadPoolExecutor aThreadPool = new ThreadPoolExecutor(
            2,
            2,
            0L,
            TimeUnit.SECONDS,
            new ArrayBlockingQueue<>(DEFAULT_QUEUE_SIZE),
            r -> new Thread(r, "aThreadPool-" + r.hashCode()));



}
